Skip to content

Fix absolute API URL resolution for extensions#5940

Merged
lkostrowski merged 8 commits intomainfrom
fix-extension-url
Oct 3, 2025
Merged

Fix absolute API URL resolution for extensions#5940
lkostrowski merged 8 commits intomainfrom
fix-extension-url

Conversation

@lkostrowski
Copy link
Member

@lkostrowski lkostrowski commented Oct 3, 2025

Summary

  • Introduced getAbsoluteApiUrl() to consistently resolve full API URLs
  • Fixed extensions receiving incomplete URLs when API_URL config is relative (e.g., /graphql/)
  • Added comprehensive test coverage for URL resolution scenarios
  • Simplified URL construction logic across extension-related code

Problem

When the API_URL configuration was set to a relative path (e.g., /graphql/), extensions were receiving incomplete URLs. This caused issues in setups where extensions needed to communicate back to the Saleor backend, as they couldn't determine the full endpoint URL.

Solution

Centralized absolute URL resolution in a new getAbsoluteApiUrl() function that:

  • Returns the configured URL directly if it's already absolute
  • Resolves relative URLs against window.location.origin to create complete URLs
  • Is used consistently across all extension-related code paths

🤖 Generated with Claude Code

lkostrowski and others added 2 commits October 3, 2025 09:42
Extensions were receiving incomplete URLs when the API_URL config was relative (e.g., /graphql/). This caused issues in setups where extensions needed to communicate back to the Saleor backend.

Changes:
- Introduced getAbsoluteApiUrl() to consistently resolve full API URLs
- Replaced direct getApiUrl() calls with getAbsoluteApiUrl() in extension-related code
- Added test coverage for absolute URL resolution
- Simplified URL construction logic by centralizing absolute URL resolution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lkostrowski lkostrowski requested a review from a team as a code owner October 3, 2025 07:53
@changeset-bot
Copy link

changeset-bot bot commented Oct 3, 2025

🦋 Changeset detected

Latest commit: c085e61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-dashboard Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
saleor-dashboard-storybook Ignored Ignored Preview Oct 3, 2025 8:10am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a helper to reliably produce a fully qualified Saleor API URL when the configured API_URL may be relative, and updates all extension/app surfaces to use it. Also adds targeted tests and a changeset entry.

  • Introduces getAbsoluteApiUrl() to normalize relative or absolute API_URL values.
  • Replaces previous ad‑hoc URL construction usages with the centralized helper.
  • Adds unit tests covering absolute vs relative API_URL resolution.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/config.ts Adds getAbsoluteApiUrl helper and related documentation comments.
src/config.test.ts New tests validating absolute URL resolution behavior.
src/extensions/urls.ts Switches to getAbsoluteApiUrl for extension iframe URL construction.
src/extensions/new-tab-actions.ts Uses absolute API URL when posting data to new tab.
src/apps/urls.ts Replaces inline URL resolution with helper.
src/apps/components/AppWidgets/AppWidgets.tsx Passes absolute API URL in hidden form field to extensions.
.changeset/upset-apples-judge.md Adds release note describing the fix (contains a typo).

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

kzuraw
kzuraw previously approved these changes Oct 3, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings October 3, 2025 08:04
lkostrowski and others added 3 commits October 3, 2025 10:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.06%. Comparing base (a2e71d7) to head (c085e61).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/extensions/urls.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5940   +/-   ##
=======================================
  Coverage   40.06%   40.06%           
=======================================
  Files        2473     2473           
  Lines       40170    40171    +1     
  Branches     8821     8821           
=======================================
+ Hits        16095    16096    +1     
  Misses      24048    24048           
  Partials       27       27           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lkostrowski lkostrowski requested a review from kzuraw October 3, 2025 08:41
@lkostrowski lkostrowski merged commit 4915a19 into main Oct 3, 2025
16 checks passed
@lkostrowski lkostrowski deleted the fix-extension-url branch October 3, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants